package com.zzyl.nursing.mapper;

import java.util.List;

import com.zzyl.common.core.domain.entity.SysUser;
import com.zzyl.nursing.domain.NursingTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.nursing.dto.NursingTaskDoDTO;
import com.zzyl.nursing.dto.NursingTaskQueryDTO;
import com.zzyl.nursing.vo.NursingTaskDetailVO;
import com.zzyl.nursing.vo.NursingTaskVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 护理任务Mapper接口
 *
 * @author ruoyi
 * @date 2024-09-27
 */
@Mapper
public interface NursingTaskMapper extends BaseMapper<NursingTask> {
    /**
     * 查询护理任务
     *
     * @param id 护理任务主键
     * @return 护理任务
     */
    public NursingTask selectNursingTaskById(Long id);

    /**
     * 查询护理任务列表
     *
     * @param nursingTask 护理任务
     * @return 护理任务集合
     */
    public List<NursingTask> selectNursingTaskList(NursingTask nursingTask);

    /**
     * 新增护理任务
     *
     * @param nursingTask 护理任务
     * @return 结果
     */
    public int insertNursingTask(NursingTask nursingTask);

    /**
     * 修改护理任务
     *
     * @param nursingTask 护理任务
     * @return 结果
     */
    public int updateNursingTask(NursingTask nursingTask);

    /**
     * 删除护理任务
     *
     * @param id 护理任务主键
     * @return 结果
     */
    public int deleteNursingTaskById(Long id);

    /**
     * 批量删除护理任务
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteNursingTaskByIds(Long[] ids);

    List<NursingTaskVO> selectNursingTaskList2(NursingTaskQueryDTO nursingTaskQueryDTO);

    NursingTaskDetailVO selectNursingTaskById2(Long id);

    /**
     * 修改护理任务
     *
     * @param nursingTask 护理任务
     * @return 结果
     */
    @Update("UPDATE nursing_task SET status = 3, cancel_reason = #{reason}, update_time = NOW() WHERE id = #{taskId}")
    int updateNursingTask2(@Param("taskId") Long taskId, @Param("reason") String reason);


    int updateNursingTaskDo(NursingTaskDoDTO nursingTaskDoDTO);

    @Update("UPDATE nursing_task " +
            "SET estimated_server_time = #{estimatedServerTime} " +
            "WHERE id = #{taskId}")
    int updateNursingTaskUpdateTime(NursingTaskDoDTO nursingTaskDoDTO);

    /**
     * 查询护理等级名称（字符串）
     *
     * @param id 护理任务主键
     * @return 护理等级名称
     */
    String selectNursingLevel(Long id);

    List<String> selectNursingLevelById(Long id);

    /**
     * 查询执行人名称
     *
     * @param userId
     */
    @Select("select *\n" +
            "from sys_user\n" +
            "where user_id=#{userId};")
    SysUser selectUpdater(Long userId);
}
